package com.darrenchan.spark.sql

import java.sql.DriverManager

/**
  * 使用code访问ThriftServer
  */
object SparkSQLThriftServerApp {
  def main(args: Array[String]): Unit = {
    Class.forName("org.apache.hive.jdbc.HiveDriver")

    //beeline -u jdbc:hive2://localhost:10000 -n hadoop 保持一致
    val conn = DriverManager.getConnection("jdbc:hive2://hadoop000:10000", "hadoop", "")
    val pstmt = conn.prepareStatement("select * from hive_wordcount")
    val rs = pstmt.executeQuery()

    while(rs.next()) {
      val context = rs.getString("context")
      println(context)
    }


    rs.close()
    pstmt.close()
    conn.close()
  }
}
